package com.antler.smt.portal.controller;

import com.antler.smt.portal.annotation.OperateCut;
import com.antler.smt.response.base.Result;
import com.antler.smt.service.portal.MessageReadHistoryService;
import com.antler.smt.utils.LogUtil;
import com.antler.smt.validate.DataValidator;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 消息推送
 *
 * @author zhangyi
 * @date 2018/5/17 18:11
 */
@RestController
@RequestMapping("/messageIsRead")
@Api(description = "消息推送")
public class MessageReadHistoryController extends BaseController{

    /**
     * 日志
     */
    private static Logger log = LogUtil.get();

    @Resource
    private MessageReadHistoryService messageIsReadService;


    /**
     *  是否阅读推送
     *
     * @param id 推送表id
     * @return
     */
    @PostMapping("/isRead")
    @ApiOperation(value = "是否阅读推送(点击此条推送，调用此方法)", httpMethod = "POST")
    @OperateCut(operationContent = "用户阅读消息")
    public Result isRead(Long id){

        DataValidator.isBlank(String.valueOf(id),"推送表id！");

        Result result = null;
            result = messageIsReadService.isRead(id,currentMember.getId());
        return result;
    }

    /**
     *  获取分类获取推送
     *
     * @return
     */
    @GetMapping("/getClassifyInfoList")
    @ApiOperation(value = "获取分类获取推送(3:已阅读4:未阅读)", httpMethod = "GET")
    public Result getClassifyInfoList(){

        Result result = null;
            result = messageIsReadService.getClassifyMessage(currentMember.getId());
        return result;
    }
}
